package sGUI;
	import java.util.Observer;
	import java.util.Observable;

	import java.rmi.Naming;
	import java.rmi.RemoteException;
	import java.rmi.NotBoundException;
	import java.rmi.RMISecurityManager;

	import java.net.MalformedURLException;

import java.rmi.Remote;

import servidor.ServidorRMI;
	
public class VentanaServidor extends javax.swing.JFrame {

	    
	   
	    
	    private String host;
	    private String port;
	    private String name;
	    
	    public VentanaServidor(String host, String port, String name) {
	        
	    	initComponents(); 

	        this.host = host;
	        this.port = port;
	        this.name = name;

	        try{

	            showMessage("Servidor funcionando y escuchando en: " + host + ":" + port);            
	        }catch(Exception e){
	            showMessage("El servidor no ha podido ser iniciado correctamente.");            
	        }
	    }    
	    
	    /** This method is called from within the constructor to
	     * initialize the form.
	     * WARNING: Do NOT modify this code. The content of this method is
	     * always regenerated by the Form Editor.
	     */
	    private void initComponents() {//GEN-BEGIN:initComponents
	        centerPanel = new javax.swing.JPanel();
	        consoleScroll = new javax.swing.JScrollPane();
	        console = new javax.swing.JTextArea();
	        topPanel = new javax.swing.JPanel();
	        tittle = new javax.swing.JLabel();
	        bottomPanel = new javax.swing.JPanel();
	        stopButton = new javax.swing.JButton();

	        setTitle("Servidor de Eventos");
	        addWindowListener(new java.awt.event.WindowAdapter() {
	            public void windowClosing(java.awt.event.WindowEvent evt) {
	                exitForm(evt);
	            }
	        });

	        consoleScroll.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 2));
	        consoleScroll.setPreferredSize(new java.awt.Dimension(320, 160));
	        console.setBackground(new java.awt.Color(204, 204, 255));
	        console.setEditable(false);
	        console.setPreferredSize(null);
	        consoleScroll.setViewportView(console);

	        centerPanel.add(consoleScroll);

	        getContentPane().add(centerPanel, java.awt.BorderLayout.CENTER);

	        topPanel.setBackground(new java.awt.Color(102, 102, 153));
	        topPanel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(51, 51, 51), 2));
	        tittle.setForeground(java.awt.Color.yellow);
	        tittle.setText("CONSOLA DEL SERVIDOR DE BIBLIOTECA DE DEUSTO");
	        topPanel.add(tittle);

	        getContentPane().add(topPanel, java.awt.BorderLayout.NORTH);

	        stopButton.setText("Parar");
	        stopButton.addActionListener(new java.awt.event.ActionListener() {
	            public void actionPerformed(java.awt.event.ActionEvent evt) {
	                stopButtonActionPerformed(evt);
	            }
	        });

	        bottomPanel.add(stopButton);

	        getContentPane().add(bottomPanel, java.awt.BorderLayout.SOUTH);

	        pack();
	        this.setEnabled(true);
	        this.setVisible(true);
	    }//GEN-END:initComponents

	    private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
	        ServidorRMI.stopServer();
	        dispose();
	    }//GEN-LAST:event_stopButtonActionPerformed
	    
	    /** Exit the Application */
	    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
	        ServidorRMI.stopServer(); 
	        dispose();
	    }//GEN-LAST:event_exitForm
	 
	        
	    // Variables declaration - do not modify//GEN-BEGIN:variables
	    private javax.swing.JPanel bottomPanel;
	    private javax.swing.JPanel centerPanel;
	    public static javax.swing.JTextArea console;
	    private javax.swing.JScrollPane consoleScroll;
	    private javax.swing.JButton stopButton;
	    private javax.swing.JLabel tittle;
	    private javax.swing.JPanel topPanel;
	    // End of variables declaration//GEN-END:variables
	   
	    public void showMessage(String message){
	        console.append(message + "\n");
	    }
	    	       
	}